#pragma once

#include <QWidget>
#include "ui_TalkWindowShell.h"
#include "BasicWindow.h"
#include <QListWidget>
#include <QMap>
#include "CustomProxyStyle.h"
#include "EmotionWindow.h"
#include <QStackedWidget>
#include <QTcpSocket>
#include <qsql.h>
#include <qsqlquerymodel.h>
#include <qsqlquery.h>
#include <qudpsocket.h>



class TalkWindow;
#include "TalkWindowItem.h"
//class EmotionWindow;

enum GroupType {
	COMPANY = 0,		//公司
	PERSONELGROUP,		//人事
	DEVELOPMENTGROUP,	//研发
	MARKETGROUP,		//市场
	PTOP,				//个人
	USER				//自己
};

#define M_PORT  12345
#define M_PORT_UDP  54321

class TalkWindowShell : public BasicWindow
{
	Q_OBJECT

public:
	TalkWindowShell(QWidget *parent = Q_NULLPTR);
	~TalkWindowShell();

	void addTalkWindow(TalkWindow *talkWindow, TalkWindowItem *talkWindowItem, const QString &uid);
	void setCurrendWidget(QWidget *widget);

	const QMap<QListWidgetItem*, QWidget*>& getTalkWindowItemMap() const;

private:
	void initControl();
	void initTcpClientSocket();
	void initUdpSocket();

	QStringList  getEmployeesList();
	bool createJSFile(QStringList & employeesList);

	QString handleReceivedMsg(QString j, QString msgType, QString data);

public slots:
	void onEmotionBtnChicked(bool);
	void onEmotionItemChicked(int);

	void onTalkWindowItemChicked(QListWidgetItem *item);

	void updateSendTcpMsg(QString &strData, int msgType, QString fileName = "");

	void processPendingData();//处理暂挂数据

private:
	Ui::TalkWindowClass ui;

	EmotionWindow *m_emotionWindow;

	QMap<QListWidgetItem*, QWidget*> m_talkWindowItemMap;

	QTcpSocket *m_tcpClientSocket;

	QUdpSocket *m_udpReceiver;
};
